package cn.usian.controller;

import cn.usian.pojo.Emp;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RequestMapping("/order")
@RestController
public class OrderController {
    @Resource
    private RestTemplate restTemplate;

    @RequestMapping("/findPage")
    public String findPage(@RequestParam(defaultValue = "1") Integer pageIndex, String name) {
        return restTemplate.getForObject("http://userservice/emp/findPage?=pageIndex=" + pageIndex + "&name=" + name, String.class);
    }

    @RequestMapping("/add")
    public String add(@RequestBody Emp emp) {
        String forObiect = restTemplate.postForObject("http://userservice/emp/add", emp, String.class);
        return forObiect;
    }

    @RequestMapping("/del")
    public String del(long id) {
        return restTemplate.getForObject("http://userservice/emp/del?id="+id,String.class);
    }
}
